package dao

import (
	"github.com/liangchao/blogo/src/common/models"
	"github.com/liangchao/blogo/src/common/utils"
)

type MessageDao struct {
	messages []models.Message
}

// AddMessage 添加消息
func (d *MessageDao) AddMessage(m *models.Message) (err error) {
	err = m.AddMessage()
	if err != nil {
		return
	}
	err = d.ToMap(m)
	return
}

func (d *MessageDao) ToMap(m *models.Message) (err error) {
	m.CreateTimeStr = utils.FormatTime(m.CreateTime)
	m.UpdateTimeStr = utils.FormatTime(m.UpdateTime)
	return
}